<%--                                                                       --%>
<%-- Copyright (c) 2004-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.beanutils.PropertyUtils" %>
<%@ page import="com.broadvision.web.util.ViewDynaBean" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<script language="JavaScript">

//
//
//
function closeWindow() {
  self.close();
}

//
// An actor has been selected. Pass the actor name back to
// the parent window's callback function 'setActor()'. And then
// close the popup window.
//
function setActor(theForm, index) {
  var aN = "theForm.elements['oneResult[" + index + "].actorName'].value";
  var actorName = eval(aN);
  var parentFormName = theForm.parentFormName.value;
  var parentFieldName = theForm.parentFieldName.value;
  window.opener.setActor(parentFormName, parentFieldName, actorName);
  window.close();
}

//
//
//
function selectActor(theForm, index) {
  var aN = "theForm.elements['oneResult[" + index + "].actorName'].value";
  var actorName = eval(aN);
  theForm.selectedActor.value = actorName;
  theForm.submit();
}

//
//
//
function removeActor(theForm, index) {
  var aN = "theForm.elements['oneResultForRemove[" + index + "].actorName'].value";
  var actorName = eval(aN);
  theForm.removeActor.value = actorName;
  theForm.submit();
}

//
//
//
function setSelectedActors(theForm) {
  var parentFormName = theForm.parentFormName.value;
  var parentFieldName = theForm.parentFieldName.value;
  var actors = new Array();
  var selected = theForm.selected.value;

  if (selected.length > 0) {
    actors = selected.split("$#@!");
  }

  window.opener.setSelectedActors(parentFormName, parentFieldName, actors);
  window.close();
}

</script>


<bean:define id="multiselect" name="actorFindView" property="multiselect"/>

<%
  String actionPath = "/bp/actorSearchPopup.do";
  if (((Boolean) multiselect).booleanValue()) {
    actionPath = "/bp/actorMultiSearchPopup.do";
  }
%>
    <html:form action="<%= actionPath %>">
      <html:hidden property="parentFormName"/>
      <html:hidden property="parentFieldName"/>
      <html:hidden property="selected"/>
      <html:hidden property="selectedActor"/>
      <html:hidden property="removeActor"/>
      <html:hidden property="packageOid"/>

      <!-- Zone 5 starts here.  -->
      <table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
        <tr>
          <td valign="top" width="100%">
            <div class="generalWrapRight">
              <html:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
                <bean:message key="button.close"  bundle="bp.messages"/>
              </html:button>
            </div> 

            <table class="labelForm" width="100%" border="0"
cellspacing="0" cellpadding="2" summary="Actor search criteria table">
              <tr> 
                <td width="10%" nowrap><b><bean:message key="bp.user.actorFind.label.searchActor" bundle="bp.messages"/>:</b><br>&nbsp;</td>

                  <td width="10%" nowrap>
                    <html:text  name="actorFindForm" property="actorName" size="20" maxlength="80" />
                  </td>

                <td width="60%" nowrap>
                  <html:submit property="gotoBtn" styleClass="inputButton">
                    <bean:message key="button.goto" bundle="bp.messages"/>
                  </html:submit>
                </td>
              </tr>
            </table>
			
            <!-- Start Result List here -->
            <%
              ViewDynaBean actorFindView = (ViewDynaBean) request.getAttribute("actorFindView");
              List searchResultList = (List) PropertyUtils.getSimpleProperty(actorFindView, "searchResultList");
              int tmpLen = (searchResultList == null) ? 0 : searchResultList.size();
              Integer searchResultListLength = new Integer(tmpLen);
            %>

            <div class="pageSubtitle">
              <span class="left"><bean:message key="bp.user.actorFind.searchResult" arg0="<%= searchResultListLength.toString() %>"  bundle="bp.messages"/></span>
              <span class="right">&nbsp;</span>
            </div> 

            <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
              <tr class="listHeader">
                <th id="Name" align="left"><bean:message key="bp.user.actorFind.header.name" bundle="bp.messages"/></th>
                <th id="Actions" align="left" nowrap><bean:message key="bp.user.actorFind.header.actions" bundle="bp.messages"/></th>
              </tr>

              <logic:empty name="actorFindView" property="searchResultList">
                <tr class="listEven">
                  <td colspan=3 align="center">
                <logic:equal name="actorFindForm" property="executeSearch" value="true">
                  <bean:message key="bp.user.actorFind.noMatch" bundle="bp.messages"/>
                </logic:equal>
                <logic:equal name="actorFindForm" property="executeSearch" value="false">
                  &nbsp;
                </logic:equal>
                  </td>
                </tr>
              </logic:empty>
              <logic:notEmpty name="actorFindView" property="searchResultList">
                <logic:iterate id="oneResult" name="actorFindView" property="searchResultList" indexId="index">
                  <tr class='<%= index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'>
                    <td headers="Name">
			
			<bean:define id="actorName" name="oneResult" property="actorName"/>
			 <% String  temp = (String )pageContext.getAttribute("actorName");   
			 if(temp != null && temp.equalsIgnoreCase("LaunchUser"))
		                     {			
								 %>
		                     <bean:message key="bp.process.processInstanceTaskDetail.LaunchUser" bundle="bp.messages"/>
		                     <%}
		                     else{%>
		                      <%=temp%>
		                    <% }%>
			 
			
		
			 	  
                     
                    </td>
                    <td nowrap align="left" headers="Actions">
                      <html:hidden name="oneResult" property="actorName" indexed="true"/>
<logic:equal name="actorFindView" property="multiselect" value="true">
                      <a href="JavaScript:selectActor(document.forms[0], '<bean:write name="index"/>')">
                        <img src="<%=request.getContextPath()%>/bp/images/action/icon_add.gif" border="0" alt='<bean:message key="image.alt.add" bundle="bp.messages"/>' title='<bean:message key="image.alt.add" bundle="bp.messages"/>' >
                      </a>
</logic:equal>
<logic:equal name="actorFindView" property="multiselect" value="false">
                      <a href="JavaScript:setActor(document.forms[0], '<bean:write name="index"/>')">
                        <img src="<%=request.getContextPath()%>/bp/images/action/icon_add.gif" width="15" height="15" border="0" alt='<bean:message key="image.alt.selectitem" bundle="bp.messages"/>' title='<bean:message key="image.alt.selectitem" bundle="bp.messages"/>' >
                      </a>
</logic:equal>
                    </td>
                  </tr>
                </logic:iterate>
              </logic:notEmpty>
            </table>
            <!--end result list here-->

            <div class="pageButtonWrap" align="right">
              <html:button property="cancelBtn" styleClass="pageButton" onclick="javascript:closeWindow()">
                <bean:message key="button.cancel"  bundle="bp.messages"/>
              </html:button>
            </div>

<logic:equal name="actorFindView" property="multiselect" value="true">

          </td>
        </tr>
        <tr>
          <td>
            <div class="pageSubtitle">
              <span class="left"><bean:message key="bp.user.actorFind.selectedActorsSubtitle" bundle="bp.messages"/></span>
              <span class="right">&nbsp;</span>
            </div>

            <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
              <tr class="listHeader">
                <th id="Name" align="left"><bean:message key="bp.user.actorFind.header.name" bundle="bp.messages"/></th>
                <th id="Actions" align="left" nowrap><bean:message key="bp.user.actorFind.header.actions" bundle="bp.messages"/></th>
              </tr>

              <logic:empty name="selectedActorView" property="selectedList">
                <tr class="listEven">
                  <td colspan=3 align="center"><bean:message key="bp.user.actorFind.noSelectedActors" bundle="bp.messages"/></td>
                </tr>
              </logic:empty>
              <logic:notEmpty name="selectedActorView" property="selectedList">
                <logic:iterate id="oneResultForRemove" name="selectedActorView" property="selectedList" indexId="index">
                  <tr class='<%= index.intValue() % 2 == 0 ? "listEven" : "listOdd"%>'>
                    <td headers="Name">
                    
                     <bean:define id="actorName" name="oneResultForRemove" property="actorName"/>
			 <% String  temp = (String )pageContext.getAttribute("actorName");   
			 if(temp != null && temp.equalsIgnoreCase("LaunchUser"))
		                     {			
								 %>
		                     <bean:message key="bp.process.processInstanceTaskDetail.LaunchUser" bundle="bp.messages"/>
		                     <%}
		                     else{%>
		                      <%=temp%>
		                    <% }%>

					 
                    </td>
                    <td nowrap align="left" headers="Actions">
                      <html:hidden name="oneResultForRemove" property="actorName" indexed="true"/>
                      <a href="JavaScript:removeActor(document.forms[0], '<bean:write name="index"/>')">
                        <img src="<%=request.getContextPath()%>/bp/images/action/icon_remove.gif" border="0" alt='<bean:message key="image.alt.remove" bundle="bp.messages"/>' title='<bean:message key="image.alt.remove" bundle="bp.messages"/>' >
                      </a>
                    </td>
                  </tr>
                </logic:iterate>
              </logic:notEmpty>
            </table>

            <div class="pageButtonWrap" align="right">
              <input hspace="40" type="button" name="btn_action" class="pageButton" value="<bean:message key="button.done" bundle="bp.messages"/>" onClick="JavaScript:setSelectedActors(document.forms[0])">
            </div>

          </td>
        </tr>
</logic:equal>

      </table>
      <!--end zone 5 content here -->
      <input type="hidden" name="executeSearch" value="1"/>
    </html:form>

